package com.hotacorp.opencloud.flowservice.controller;

import java.util.Set;

import org.springframework.security.core.context.SecurityContextHolder;

import com.hotacorp.opencloud.common.authcommon.SysUserBean;

/**
 * 所有需要用户信息的控制器的父类，如果控制器中需要用户信息等相关信息，可以直接继承本类
 * @author lwg
 *
 */
public abstract class AbstractController {
	
	protected SysUserBean getUser() {
    	SysUserBean userDetails = (SysUserBean) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
		return userDetails;
	}

	protected Long getUserId() {
		return getUser().getId();
	}
	protected Long getDepId() {
		return getUser().getDepid();
	}
	protected String getNickname() {
		return getUser().getNickname();
	}
	protected String getPhone() {
		return getUser().getPhone();
	}
	protected Long getTenantid() {
		return getUser().getTenantid();
	}
	protected String getUsername() {
		return getUser().getUsername();
	}
	protected Set<String> getAuthoritys() {
		return getUser().getAuthoritys();
	}
}
